package com.wu.service;

import com.wu.entity.User;
import com.wu.mapper.UserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 20521
 */
@Service
public class UserService {
    final
    UserMapper userMapper;

    public UserService(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public List<User> queryUserList(){
        return userMapper.queryUserList();
    }

    public boolean addUser(User user) {
        String name = user.getName();
        if (name==null || name.isEmpty()){
            return false;
        }else {
            userMapper.addUser(user);
            return true;
        }
    }

    public boolean delUser(String name) {
        if (name==null || name.isEmpty()){
            return false;
        }else {
            userMapper.delUser(name);
            return true;
        }
    }
}
